package day16;

public class demo1 {
    public static void main(String[] args) {
String str="A%sC%sE";
char[]arg={'B','D','F'};
        System.out.println(formatString(str, arg));
    }

    public static String formatString (String str, char[] arg) {
        StringBuffer ret=new StringBuffer();
        int cur=0;
        for (int i = 0; i <str.length() ; i++) {
            if(str.charAt(i)!='%'){
                ret.append(str.charAt(i));
            }else {
                ret.append(arg[cur++]);
                i++;
            }
        }
        while (cur< arg.length){
            ret.append(arg[cur++]);
        }
     return ret.toString();
    }

}
